<?php
/**
 * Created by PhpStorm.
 * User: myl
 * Date: 2018/9/7
 * Time: 13:29
 */
namespace app\admin\controller;

use app\admin\logic\OrderLogic;
use think\AjaxPage;
use think\console\command\make\Model;
use think\Page;
use think\Verify;
use think\Db;
use app\admin\logic\UsersLogic;
use app\common\model\Withdrawals;
use app\common\model\Users;
use think\Loader;

class Live extends Base {

    /**
     * 直播用户列表
     * @return string
     */
    public function liveUser()
    {
        return $this->fetch();
    }

    /**
     * 直播记录列表
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function liveList()
    {
        $arr = [];
        $status = I("post.cat_id");
        $user_name = I("post.keywords");

        if ($status) {
            $map['status'] = $status;
            $arr["cat_id"] = $status;
        }
        if ($user_name) {
            $map['user_name'] = ['like','%'.$user_name."%"];
            $arr["keywords"] = $user_name;
        }
        $count = Db::name('live')->where($map)->count();
        $Page = new Page($count, 20);
        $show = $Page->show();
        $prom_list = Db::name('live')->where($map)->order("live_id desc")->limit($Page->firstRow . ',' . $Page->listRows)->select();
        $this->assign('prom_list', $prom_list);
        $this->assign('page', $show);// 赋值分页输出
        $this->assign('pager', $Page);
        $this->assign('arr', $arr);
       return $this->fetch();
    }

    public function onRol()
    {
        return '未开启！';
    }
}